//
//  main.cpp
//  求位数和.cpp
//
//  Created by 黄靖文 on 2018/6/6.
//  Copyright © 2018年 黄靖文. All rights reserved.
#include<iostream>
using namespace std;
int countNum(int n)
{
    int total=0;
    int count=0;
    int init=n;
    while(init!=0)
    {
        count=init%10;
        total+=count;
        init=init/10;
        //total+=count;
    }
    return total;
}
int addNum(int n)
{
    int num=0;
    for(int i=1;i<=n;i++)
        num+=countNum(i);
    return num;
    
}
int main()
{
    //int total=12;
    int n;
    printf("Please intput a number:\n");
    cin>>n;
    //cout<<n;
    //cout<<countNum(total)<<endl;
    
    cout<<"all the num adding is:"<<addNum(n)<<endl;
    return 0;
}

